import { PlainObject } from '@/bean/base';
import { CommentDTO } from '@/bean/dto';
import {
  PageResponse,
  PlainResponse,
  QueryCommentModel,
  QueryCommentPageModel,
} from '@/bean/xhr';
import ajax from '.';
import { IDataType } from './type';

class CommentService {
  // Page = (params: QueryPageModel): Promise<PageResponse<ArticleDTO>> =>
  //   ajax.get('/article/page', { params });

  public numberOfPeople = (): Promise<PlainResponse<number>> =>
    ajax.get('/comment/number_of_people');

  public total = (): Promise<PlainResponse<number>> =>
    ajax.get('/comment/total');

  // 这里的参数貌似很难判断,所以写出具体参数类型
  public add = (params: QueryCommentModel): Promise<IDataType> =>
    ajax.post('/comment/add', params);

  public page = (
    params: QueryCommentPageModel
  ): Promise<PageResponse<CommentDTO>> => {
    return ajax.get('/comment/page', { params });
  };
}

export const commentService = new CommentService();
